<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>业务模块-会员</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" />
    <style type="text/css">
        .layui-table tbody .layui-table-cell {
            height: auto;
            line-height: 88px;
        }
    </style>
</head>

<body class="childrenBody">
<form class="layui-form" method="post" action="/webMember/export">
    <blockquote class="layui-elem-quote quoteBox" id="tool">
        <div class="layui-inline">
            <label class="layui-input-inline">卡号</label>
            <label class="layui-input-inline">
                <input type="text" class="layui-input" name="cardNo" placeholder="请输入卡号" /></label>
            <label class="layui-input-inline">姓名</label>
            <label class="layui-input-inline">
                <input type="text" class="layui-input" name="name" placeholder="请输入姓名" /></label>
            <label class="layui-input-inline">手机号</label>
            <label class="layui-input-inline">
                <input type="text" class="layui-input" name="phone" placeholder="请输入手机号" /></label>
            <label class="layui-input-inline">银行卡号</label>
            <label class="layui-input-inline">
                <input type="text" class="layui-input" name="bankCard" placeholder="请输入银行卡号" /></label>
            <a class="layui-btn search_btn" lay-submit="" lay-filter="seacherBtn">搜索</a>
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="exportBtn"  type="submit" >导出</button>
        </div>
    </blockquote>
    <table id="entityList" lay-filter="entityList"></table>
</form>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['jquery', 'pageUtil', 'table', 'dialogUtil','dateUtil','fileUtil'],
    function() {
        var $ = layui.jquery,
            fileUtil = layui.fileUtil,
            dateUtil = layui.dateUtil,
            table = layui.table,
            dialogUtil = layui.dialogUtil,
            pageUtil = layui.pageUtil;
        var url = "/webMember/page";
        var cols = [{
            type: 'checkbox',
            fixed: 'left'
        },
            {
                type: 'numbers',
                title: '序号'
            },
            {
                field: 'openid',
                title: '微信标识',
                align: 'center',
                width:250
            },
            {
                field: 'cardNo',
                title: '会员卡号',
                align: 'center'
            },
            {
                field: 'name',
                title: '姓名',
                align: 'center'
            },
            {
                field: 'nickName',
                title: '昵称',
                align: 'center'
            },
            {
                field: 'phone',
                title: '手机号',
                align: 'center'
            },
            {field: 'headImage', title: '头像',align:'center', templet:function(d){
                if(d.headImage != null && d.headImage != ""){
                    return "<img lay-event ='showPicture'  src='"+d.headImage+"' style='width:auto; max-width: 96%; height: 80px;'/>";
                }else{
                    return "无";
                }
            },width:100},
            {
                field: 'bankCard',
                title: '银行卡号',
                align: 'center'
            },
            {
                field: 'alipay',
                title: '支付宝',
                align: 'center'
            },
            {
                field: 'freezeMoney',
                title: '冻结余额',
                align: 'center'
            },
            {
                field: 'money',
                title: '可提现余额',
                align: 'center'
            },
            {
                field: 'creditScore',
                title: '信用分',
                align: 'center',
                templet:function(d){
                    return d.creditScore + '<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="creditScoreEdit"> 设置 </a>';
                }
            },
            {
                field: 'createTime',
                title: '创建时间',
                width: 190,
                align: 'center',
                templet: function(d) {
                    return dateUtil.formatDate(new Date(d.createTime), "yyyy-MM-dd hh:mm:ss");
                }
            }];
        var tableIns = pageUtil.initDate(cols, url, true);

        table.on('tool(entityList)',
            function(obj) {
                var layEvent = obj.event,
                    data = obj.data;
                if (layEvent === 'edit') {
                    pageUtil.editPopup("编辑", "/webMember/getEntity?id=" + data.id);
                } else if (layEvent === 'showPicture') {
                    fileUtil.imageSingleShow(data.headImage);
                }else if (layEvent === 'del') {
                    pageUtil.delete("确定删除该项吗？", "/webMember/delete", {
                            "id": data.id,
                            "_method": "DELETE"
                        },
                        function(data) {
                            tableIns.reload();
                        });
                } else if (layEvent === 'creditScoreEdit') {
                    // 设置用户
                    var id = data.id;
                    var creditScore = "";
                    if(data.creditScore != null && data.creditScore != ""){
                        creditScore = data.creditScore;
                    }
                    var index = layer.open({
                        type: 1,
                        title:'设置',
                        area: ['200px', 'auto'], //宽高
                        btn:['确定','取消'],
                        content: '<div style="padding: 15px !important;">'+
                        '<form class="layui-form" action="">'+
                        '<div class="layui-form-item layui-form-text" >'+
                        ' <input type="text" class="layui-input" value="'+creditScore+'" id="creditScore" name="creditScore" />'+
                        '</div>'+
                        '</form>'+
                        '</div>'
                        ,success:function(){

                        }
                        ,yes:function (){
                            var creditScore = $("#creditScore").val();
                            if(creditScore == null || creditScore == ""){
                                dialogUtil.alert("请填写商店名称");
                                return false;
                            }
                            var reg = /^([1-9][0-9]{0,1}|100)$/;
                            if (!reg.test(creditScore)){
                                dialogUtil.alert("商店名称不能超过50个字");
                                return false;
                            }
                            var params={
                                "id":id,
                                "creditScore":creditScore
                            }
                            $.post("/webMember/updateCreditScore", params, function (result) {
                                layer.close(index);
                                if (result.code === 0) {
                                    //操作成功
                                    tableIns.reload();
                                } else {
                                    //操作失败
                                    dialogUtil.alert(result.msg);
                                }
                            }, "json");
                        }
                        ,btn2: function(index, layero){

                        }
                    });
                }
            });
    })</script>
</body>

</html>